//
//  DBUtility.h
//  ChatForHot
//
//  Created by FLY on 2018/10/17.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDatabase.h"
#import "FMDatabaseQueue.h"


#define DB_FILE_NAME @"chat.sqlite3"
//#define DB_ERROR_LOG(a) if ([db hadError]) NSLog(@"sql err in class:%@/%@/%@;%d; %@; %@", a, [self class], NSStringFromSelector(_cmd), [db lastErrorCode], [db lastErrorMessage], sql);

NS_ASSUME_NONNULL_BEGIN

@interface DBUtility : NSObject


@property (nonatomic,retain) FMDatabaseQueue* fmdbQueue;

/**
 DB share
 */
+ (id)sharedbUtility;

/**
 打开DB
 */
- (void)open;

/**
 打关闭DB
 */
- (void)close;

/**
 更新系処理
 @param sql SQL文;CREATE, INSERT, DELETE
 */
- (BOOL)executeUpdate:(NSString*)sql;


/**
 APP启动时
 */
- (void)applicationLauching;

/**
 APP关闭时
 */
- (void)applicationTerminating;

@end

/**
 DB版本处理
 */
@interface DBUtility(UpdateVersion)

/**
 获取DB版本
 */
- (void)selectVersion;

/**
 更新DB版本
 */
- (void)updateVersion;

@end

NS_ASSUME_NONNULL_END
